﻿using System;
using System.Data;
using System.Collections.Generic;
using Chenxin.Lib.Hr.Entity;
using Chenxin.Lib.Utility;
using Chenxin.Lib.Business;
using System.Text;
namespace Chenxin.Lib.Business.BLL
{
    /// <summary>
    /// 业务逻辑类t_Contract_RemarkInfo 的摘要说明。
    /// </summary>
    public class ContractRemark
    {
        public ContractRemark()
        { }
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo model)
        {
            Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {

            Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.GetList(strWhere);
        }
        
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Business.DAL.t_Contract_RemarkInfo.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo> modelList = new List<Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Business.Entity.t_Contract_RemarkInfo();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["ContractId"].ToString() != "")
                    {
                        model.ContractId = new Guid(dt.Rows[n]["ContractId"].ToString());
                    }
                    if (dt.Rows[n]["RemarkPersonId"].ToString() != "")
                    {
                        model.RemarkPersonId = new Guid(dt.Rows[n]["RemarkPersonId"].ToString());
                    }
                    model.RemarkPerson = dt.Rows[n]["RemarkPerson"].ToString();
                    model.RemarkInfo = dt.Rows[n]["RemarkInfo"].ToString();
                    if (dt.Rows[n]["BusinessType"].ToString() != "")
                    {
                        model.BusinessType = int.Parse(dt.Rows[n]["BusinessType"].ToString());
                    }
                    if (dt.Rows[n]["Status"].ToString() != "")
                    {
                        model.Status = int.Parse(dt.Rows[n]["Status"].ToString());
                    }
                    if (dt.Rows[n]["RemarkDate"].ToString() != "")
                    {
                        model.RemarkDate = DateTime.Parse(dt.Rows[n]["RemarkDate"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet getRemarkList(string strWhere, int strPageIndex, int strPageSize)
        {
            //排序
            string strOrderField = " RemarkDate desc";
            //欲选择字段列表 
            string FieldList = " RemarkPerson,RemarkInfo,Status,RemarkDate ";
            //子查询欲选择字段列表
            StringBuilder sb = new StringBuilder();
            sb.Append(" RemarkPerson,RemarkInfo,Status,RemarkDate ");

            //所要查询的表名
            string TableName = " t_Contract_RemarkInfo ";
            return Chenxin.Lib.Business.DAL.t_Contract_BaseInfo.GetList(strPageIndex, strPageSize, strOrderField, TableName, strWhere, FieldList, sb.ToString(), true);
        }

        #endregion  成员方法
    }
}

